package edu.rit.drh4818.raytracing.shaders.procedural;

import java.awt.Color;

import edu.rit.drh4818.raytracing.shaders.Shader;
import edu.rit.drh4818.raytracing.util.Intersection;

/**
 * @author Darren Headrick
 *
 */
public class SwirlShader implements Shader {

	
	/**
	 * 
	 */
	private Color color1, color2;
	
	/**
	 * Orientation of swirl.
	 */
	private int orx, ory, orz;
	
	/**
	 * 
	 * @param color1 First color.
	 * @param color2 Second color.
	 * @param orx Orientation in z dimension.
	 * @param ory Orientation in z dimension.
	 * @param orz Orientation in z dimension.
	 */
	public SwirlShader( Color color1, Color color2, int orx, int ory, int orz )
	{
		this.color1 = color1;
		this.color2 = color2;
		this.orx = orx;
		this.ory = ory;
		this.orz = orz;
	}
	
	
	/*
	 * 
	 */
	public Color getColor(Intersection in, int depth) 
	{
		boolean color1 = false;
		
		double value = Math.tan( (in.getX()*orx  + in.getY()*ory + in.getZ()*orz) / 30 ) ;
		
		if( !( value > .5 || value <= 0 && value > -.5 ) )
		{
			color1 = !color1;
		}
		
		return (color1)?this.color1:this.color2;
		
	}
}
